package global.com.loansapplication.ui.actviity.login.presenter;

import com.google.gson.Gson;

import org.greenrobot.eventbus.EventBus;

import javax.inject.Inject;

import global.com.loansapplication.base.BaseBiz;
import global.com.loansapplication.bean.SettingInfo;
import global.com.loansapplication.event.SettingInfoEvent;
import global.com.loansapplication.ui.actviity.MainActivity;
import global.com.loansapplication.ui.actviity.login.biz.SelectInfoBiz;
import global.com.loansapplication.ui.actviity.login.contract.SelectInfoContract;
import global.com.loansapplication.util.PreferencesUtils;
import global.com.loansapplication.util.StringUtils;

/**
 * Created by Administrator on 2017/10/21.
 */

public class SelectInfoPresenter implements SelectInfoContract.Presenter {


    SelectInfoContract.View view;
    SelectInfoBiz selectInfoBiz;


    @Inject
    public SelectInfoPresenter(SelectInfoContract.View view) {
        this.view = view;
    }


    @Override
    public void setBiz(BaseBiz biz) {
        selectInfoBiz = (SelectInfoBiz) biz;
    }

    @Override
    public void toMian(SettingInfo settingInfo,String type) {
        if(!StringUtils.isEmpty(type)){
            view.startAct(MainActivity.class,null);
        }
        PreferencesUtils.setStringPreferences("settingInfo",
                "settingInfo",
                new Gson().toJson(settingInfo));
        view.finishRegistetAct();
        EventBus.getDefault().post(new SettingInfoEvent(settingInfo));
    }
}
